Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paper, Ruthie Newman #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

RuthieRNewman
Copy link

No description provided.

…ick function to Square component, adds function to mark board with appropriate symbol in response to click.
Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you know you haven't gotten to detecting the winner yet, but you're pretty close. I left some notes to take a look at. Let me know if you have questions.

const [squares, setSquares] = useState(generateSquares());
const [currentPlayer, setPlayerState] = useState(PLAYER_1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also suggest you might want a state variable to keep track of the winner.

}
})
})
}

const checkForWinner = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting this function is still essentially blank.

I suggest making a loop that goes through the rows checking to see if:

squares[i][0].value === squares[i][1].value and squares[i][0].value === squares[i][2].value

Then do something similar for the columns. The diagonals you have to do manually.

})
});

const squareComponents = flatList.map(data => <Square id={data.id} value={data.value} onClickCallback={onClickCallback} ></Square>)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants